package com.jkhan.demo.threads;

/**
 * @ClassName ThreadTest
 * @Description TODO
 * @Author hjk
 * @Date 2022/1/3 21:02
 **/

/**
 * 多线程1：继承Thread
 * 1.创建继承Thread的子类
 * 2.重写run方法
 * 3.创建Thread类的子类的对象
 * 4.通过子类调用start()
 */
public class ThreadTest1 {
    public static void main(String[] args) {
        MyThread t1 = new MyThread();
        t1.start();

        MyThread t2 = new MyThread();
        t2.start();

        for (int i = 0; i < 100; i++) {
            if (i % 2 == 0) {
                System.out.println(Thread.currentThread().getName() + ":" + i + "**********");
            }
        }

    }
}

class MyThread extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if (i % 2 == 0) {
                System.out.println(Thread.currentThread().getName() + ":" + i);
            }
        }
    }
}
